
package cn.edu.scau.cmi.hombio.service;

import cn.edu.scau.cmi.hombio.domain.Employee;
import cn.edu.scau.cmi.hombio.domain.Task;
import cn.edu.scau.cmi.hombio.domain.TaskManage;

import java.util.List;
import java.util.Set;

import org.junit.Test;

import org.junit.runner.RunWith;

import org.springframework.beans.factory.annotation.Autowired;

import org.springframework.beans.factory.support.DefaultListableBeanFactory;

import org.springframework.context.ApplicationContext;

import org.springframework.mock.web.MockHttpServletRequest;

import org.springframework.test.context.ContextConfiguration;
import org.springframework.test.context.TestExecutionListeners;

import org.springframework.test.context.junit4.SpringJUnit4ClassRunner;

import org.springframework.test.context.support.DependencyInjectionTestExecutionListener;
import org.springframework.test.context.support.DirtiesContextTestExecutionListener;

import org.springframework.test.context.transaction.TransactionalTestExecutionListener;

import org.springframework.transaction.annotation.Transactional;

import org.springframework.web.context.request.RequestContextHolder;
import org.springframework.web.context.request.RequestScope;
import org.springframework.web.context.request.ServletRequestAttributes;
import org.springframework.web.context.request.SessionScope;

/**
 * Class to run the service as a JUnit test. Each operation in the service is a separate test.
 *
 */

@RunWith(SpringJUnit4ClassRunner.class)
@TestExecutionListeners({
		DependencyInjectionTestExecutionListener.class,
		DirtiesContextTestExecutionListener.class,
		TransactionalTestExecutionListener.class })
@ContextConfiguration(locations = {
		"file:./resources/pigRs-security-context.xml",
		"file:./resources/pigRs-service-context.xml",
		"file:./resources/pigRs-dao-context.xml",
		"file:./resources/pigRs-web-context.xml" })
@Transactional
public class TaskManageServiceTest {

	/**
	 * The Spring application context.
	 *
	 */
	@SuppressWarnings("unused")
	private ApplicationContext context;

	/**
	 * The service being tested, injected by Spring.
	 *
	 */
	@Autowired
	protected TaskManageService service;

	/**
	 * Instantiates a new TaskManageServiceTest.
	 *
	 */
	public TaskManageServiceTest() {
		setupRequestContext();
	}

	/**
	 * Operation Unit Test
	* Return a count of all TaskManage entity
	* 
	 */
	@Test
	public void countTaskManages() {
		Integer response = null;
		response = service.countTaskManages();
		// TODO: JUnit - Add assertions to test outputs of operation: countTaskManages
	}

	/**
	 * Operation Unit Test
	* Load an existing TaskManage entity
	* 
	 */
	@Test
	public void loadTaskManages() {
		Set<TaskManage> response = null;
		response = service.loadTaskManages();
		// TODO: JUnit - Add assertions to test outputs of operation: loadTaskManages
	}

	/**
	 * Operation Unit Test
	* Return all TaskManage entity
	* 
	 */
	@Test
	public void findAllTaskManages() {
		// TODO: JUnit - Populate test inputs for operation: findAllTaskManages 
		Integer startResult = 0;
		Integer maxRows = 0;
		List<TaskManage> response = null;
		response = service.findAllTaskManages(startResult, maxRows);
		// TODO: JUnit - Add assertions to test outputs of operation: findAllTaskManages
	}

	/**
	 * Operation Unit Test
	* Save an existing Employee entity
	* 
	 */
	@Test
	public void saveTaskManageEmployee() {
		// TODO: JUnit - Populate test inputs for operation: saveTaskManageEmployee 
		Integer id = 0;
		Employee related_employee = new cn.edu.scau.cmi.hombio.domain.Employee();
		TaskManage response = null;
		response = service.saveTaskManageEmployee(id, related_employee);
		// TODO: JUnit - Add assertions to test outputs of operation: saveTaskManageEmployee
	}

	/**
	 * Operation Unit Test
	* Save an existing TaskManage entity
	* 
	 */
	@Test
	public void saveTaskManage() {
		// TODO: JUnit - Populate test inputs for operation: saveTaskManage 
		TaskManage taskmanage = new cn.edu.scau.cmi.hombio.domain.TaskManage();
		service.saveTaskManage(taskmanage);
	}

	/**
	 * Operation Unit Test
	* Delete an existing Task entity
	* 
	 */
	@Test
	public void deleteTaskManageTask() {
		// TODO: JUnit - Populate test inputs for operation: deleteTaskManageTask 
		Integer taskmanage_id = 0;
		Integer related_task_id = 0;
		TaskManage response = null;
		response = service.deleteTaskManageTask(taskmanage_id, related_task_id);
		// TODO: JUnit - Add assertions to test outputs of operation: deleteTaskManageTask
	}

	/**
	 * Operation Unit Test
	* Delete an existing Employee entity
	* 
	 */
	@Test
	public void deleteTaskManageEmployee() {
		// TODO: JUnit - Populate test inputs for operation: deleteTaskManageEmployee 
		Integer taskmanage_id_1 = 0;
		Integer related_employee_id = 0;
		TaskManage response = null;
		response = service.deleteTaskManageEmployee(taskmanage_id_1, related_employee_id);
		// TODO: JUnit - Add assertions to test outputs of operation: deleteTaskManageEmployee
	}

	/**
	 * Operation Unit Test
	* Save an existing Task entity
	* 
	 */
	@Test
	public void saveTaskManageTask() {
		// TODO: JUnit - Populate test inputs for operation: saveTaskManageTask 
		Integer id_1 = 0;
		Task related_task = new cn.edu.scau.cmi.hombio.domain.Task();
		TaskManage response = null;
		response = service.saveTaskManageTask(id_1, related_task);
		// TODO: JUnit - Add assertions to test outputs of operation: saveTaskManageTask
	}

	/**
	 * Operation Unit Test
	* Delete an existing TaskManage entity
	* 
	 */
	@Test
	public void deleteTaskManage() {
		// TODO: JUnit - Populate test inputs for operation: deleteTaskManage 
		TaskManage taskmanage_1 = new cn.edu.scau.cmi.hombio.domain.TaskManage();
		service.deleteTaskManage(taskmanage_1);
	}

	/**
	 * Operation Unit Test
	 */
	@Test
	public void findTaskManageByPrimaryKey() {
		// TODO: JUnit - Populate test inputs for operation: findTaskManageByPrimaryKey 
		Integer id_2 = 0;
		TaskManage response = null;
		response = service.findTaskManageByPrimaryKey(id_2);
		// TODO: JUnit - Add assertions to test outputs of operation: findTaskManageByPrimaryKey
	}

	/**
	 * Autowired to set the Spring application context.
	 *
	 */
	@Autowired
	public void setContext(ApplicationContext context) {
		this.context = context;
		((DefaultListableBeanFactory) context.getAutowireCapableBeanFactory()).registerScope("session", new SessionScope());
		((DefaultListableBeanFactory) context.getAutowireCapableBeanFactory()).registerScope("request", new RequestScope());
	}

	/**
	 * Sets Up the Request context
	 *
	 */
	private void setupRequestContext() {
		MockHttpServletRequest request = new MockHttpServletRequest();
		ServletRequestAttributes attributes = new ServletRequestAttributes(request);
		RequestContextHolder.setRequestAttributes(attributes);
	}
}
